package com.wy.model;

import java.util.Date;
import java.util.List;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotBlank;

import com.alibaba.fastjson.annotation.JSONField;
import com.wy.annotation.Unique;
import com.wy.base.AbstractPager;
import com.wy.valid.ValidEdit;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@ApiModel("用户主表")
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "ti_User")
public class User extends AbstractPager {

	private static final long serialVersionUID = 1L;

	@ApiModelProperty("用户编号")
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NotBlank(groups = ValidEdit.class)
	private Integer userId;

	@ApiModelProperty("用户名")
	@NotBlank(message = "用户名不能为空")
	@Unique
	private String username;

	@ApiModelProperty("用户密码")
	@JSONField(serialize = false)
	private String password;

	@ApiModelProperty("真实姓名")
	private String realname;

	@ApiModelProperty("性别,男,女,中性,前端写死,不从数据库拿")
	@NotBlank(message = "性别不能为空")
	private String sex;

	@ApiModelProperty("用户身份证")
	@Unique
	private String idcard;

	@ApiModelProperty("用户手机号")
	@NotBlank(message = "用户手机号不能为空")
	@Unique
	private String userphone;

	@ApiModelProperty("用户头像")
	private String userphoto;

	@ApiModelProperty("邮箱")
	@NotBlank(message = "邮箱不能为空")
	private String email;

	@ApiModelProperty("用户部门")
	@NotBlank(message = "用户所属部门不能为空")
	private String departId;

	@ApiModelProperty("用户状态")
	private String state;

	@ApiModelProperty("新增用户时间")
	private Date createtime;

	@ApiModelProperty("更新时间")
	private Date updatetime;

	@Transient
	private UserEx userEx;

	@Transient
	private List<Role> roles;

	@Transient
	private String token;
}